<!DOCTYPE html>
<html>
<head>
    <style>
        body {
            font-family: Tahoma, Geneva, sans-serif;
        }

        div {
            display: inline;
        }
    </style>
    <script>
        function updateStats(memuse) {
            document.getElementById('rss').innerHTML = memuse;

        }
        var host = window.document.location.host.replace(/:.*/, '');
        var ws = new WebSocket('ws://' + host + ':8080');
        ws.onmessage = function (event) {
            updateStats(event.data);
        };

        ws.onopen = function (openEvent) {
            console.info(openEvent);
        };


        ws.onerror = function (errorEvent) {
            console.info(errorEvent);
        };

        ws.onclose = function (closeEvent) {
            console.info(closeEvent);
        };

        function testit(){
            var msg = document.getElementById('test').value;
            if(ws.readyState == 1){
                ws.send(msg);
            } else {
                console.info("ws is not open:" + ws.readyState);
            }

        }


    </script>
</head>
<body>
<strong>Server Stats</strong><br>
<div id='rss'></div><br>
<input type="text" id="test" /><button onclick="testit()">TEST</button>
</body>
</html>
